/*
 * find_marker_server.h
 *
 *  Created on: Jan 21, 2013
 *      Author: michiel
 */

#include "servers/base_server.h"
#include "rp_states/FindMarkerAction.h"
#include "ar_pose/ARMarkers.h"

#ifndef FIND_MARKER_SERVER_H_
#define FIND_MARKER_SERVER_H_

class FindMarkerAction : BaseServer {
/*
 * Variables
 */
private:
	unsigned int _total_markers;
	unsigned int _search_id;
	bool _searching;
protected:
	ros::Subscriber markers_sub_;

	actionlib::SimpleActionServer<rp_states::FindMarkerAction> as_;
	rp_states::FindMarkerFeedback feedback_;
	rp_states::FindMarkerResult result_;
public:

/*
 * Functions
 */
private:
protected:
	void markerCallback(const ar_pose::ARMarkers::ConstPtr &msg);
	inline unsigned int getTotalMarkers();
	inline unsigned int getSearchID();
	inline void setSearchID(unsigned int id);
	inline bool getSearching();
	inline void setSearching(bool state);
public:
	FindMarkerAction(std::string name);
	~FindMarkerAction();
	void execute(const rp_states::FindMarkerGoalConstPtr &goal);
};


#endif /* FIND_MARKER_SERVER_H_ */
